import java.io.IOException;
import java.util.Enumeration;

import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;

import tool.EnumerationUtils;


public class MoviesListSetup {
	
	private static final String MOVIES_DIR
		= "file:///E:/Data/RDVX";
	
	public static Mp3File[] setup() {
		FileConnection connection;
		int count = 0;
		Enumeration mp3s = null;

		try {
			connection = (FileConnection) Connector.open(MOVIES_DIR);
			mp3s = connection.list("*.mp3", true);
			count = EnumerationUtils.getCount(mp3s);
			mp3s = connection.list("*.mp3", true);
			connection.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

		Mp3File[] newMp3s = new Mp3File[count];
		int index = 0;

		while (mp3s.hasMoreElements()) {
			String mp3 = (String) mp3s.nextElement();
			Mp3File mp3File = new Mp3File(MOVIES_DIR, mp3);
			newMp3s[index++] = mp3File;
		}
		return newMp3s;
	}
}
